import { nanoid } from 'nanoid'

type LDMessageType = 'llm' | 'user'

export interface LDMessage {
  id: string
  type: LDMessageType
  content: string
}

class LDMessageImpl implements LDMessage {
  id: string
  type: LDMessageType
  content: string
  constructor(type: LDMessageType, content: string) {
    this.id = nanoid()
    this.type = type
    this.content = content
  }
}

function createUserMessage(content: string) {
  return new LDMessageImpl('user', content)
}

function createLLMMessage(content: string) {
  return new LDMessageImpl('llm', content)
}

export interface LDFile {
  id: string
  file: File
}

class LDFileImpl implements LDFile {
  id: string
  file: File
  constructor(file: File) {
    this.id = nanoid()
    this.file = file
  }
}

function createFile(file: File) {
  return new LDFileImpl(file)
}

const ld = {
  createUserMessage,
  createLLMMessage,
  createFile,
}

export { ld }
